define(['jquery',
        'jqureyui',
        'underscore',
        'handlebar',
        'backbone',        
        'views/product/VProducts',
        'views/filters/VFilters',
        'helpers/getGeoLocationInfo',
        'text!../../templates/common/pageHeader.html',

        ],
function ($,
          jqueryui,
         _,
         Handlebar,
         Backbone,        
         VProducts,
         VFilters,
         GetGeoLocationInfo,
         PageHeader         
                 ){
    
      
    window.placeId = 'All';
    // vsearchItem = "";
        
   window.VHeader = Backbone.View.extend({
        el: $('header'),               
        initialize: function () {
           
           //console.log(GetGeoLocationInfo);
            var getGeoLocationInfo = new GetGeoLocationInfo();
            getGeoLocationInfo.getCurrentLocation(function (address) {
               //debugger;
                var temp = address;
            }, function (ERROR) {

            });
            //var getGeoLocationInfo = new GetGeoLocationInfo();
            //var temp = GetGeoLocationInfo.initialize();
            //var getGeoLocationInfo = new GetGeoLocationInfo();
            this.render();
        },
       
        render:function(){
            this.$el.html(PageHeader);           
        },
         events:{
              'keypress input#searchItem':'enableENTERBtnForSearch',
              'change select#selectCategoryDrpDown':'selectCategory',
              'click #btnSearchItem':'searchProducts',
              //responsive Icon
              'click .srchIcon':'searchProducts'              
        },
         enableENTERBtnForSearch: function (e) {            
            if (e.keyCode == 13) {
                this.searchProducts($('#searchItem').val());
              }
        },
        selectCategory: function () {
           
            window.placeId = $('#selectCategoryDrpDown option:selected').text();
            //window.selectedCity = placeId;
        },
        searchProducts: function (vsearchItem) {          
            //show filter
            this.loadFilter();
            $('#searchingProdcutName').html(vsearchItem)
            window.vProducts = new VProducts();
            window.vProducts.searchByItem(placeId, vsearchItem);
        },
        loadFilter: function () {
                   
            var vFilters = new VFilters();
            var appView = new AppView();
            appView.showLeftPanel();
        }
        
    });
    return VHeader;
});